# -*- coding: utf-8 -*-
import redis
from api.base_api import settings as settings

class GetRedisValue:

    def connect_redis(self):
        pool = redis.ConnectionPool(host=settings.REDIS_HOST, port=settings.REDIS_PORT, db=settings.SESSION_REDIS_DB)
        r = redis.Redis(connection_pool=pool)
        return r

    def get_redis_verify_code(self,mobile):
        connect_redis = self.connect_redis()
        key = "VerifyCode:"+str(mobile)
        value = connect_redis.get(key)
        return value

    def learn_user_token(self, token):
        connect_redis = self.connect_redis()
        key = "TOKEN:" + str(token)
        connect_redis.delete(key)




# #清空当前db
# def clear(self):
#     return self.r.flushdb()
#
#
#
# print(get_redis_value())
#
#
#
# import redis
# import settings as settings
#
# redis_client = redis.StrictRedis(host=settings.REDIS_HOST, port=settings.REDIS_PORT,db=settings.SESSION_REDIS_DB)
# def get_session_value(session_id):
#     redis_key = "image.captcha:{0}".format(session_id)
#     redis_value = redis_client.get(redis_key)
#     return redis_value
#
#
# def get_captcha(session_id):
#     return get_session_value(session_id)